home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 79 / maccd 79.iso / multimedial / GL Tron / Source / gltron / artpack.c next >
Encoding:
C/C++ Source or Header  |  2001-05-26  |  864 b   |  37 lines  |  [TEXT/CWIE]

  1. #include "gltron.h"
  2.  
  3. char **artpack_list;
  4. int artpack_index = 0;
  5.  
  6. void initArtpacks() {
  7.   list *l, *p;
  8.   int i = 0, n = 0;
  9.  
  10.   l = readDirectoryContents(PATH_ART, NULL);
  11.   for(p = l; p->next != NULL; p = p->next)
  12.     n++;
  13.  
  14.   artpack_list = (char**) malloc((n + 1) * sizeof(char*));
  15.   
  16.   for(p = l; p->next != NULL; p = p->next) {
  17.     artpack_list[i] = (char*) malloc(strlen( (char*) p->data ) + 1);
  18.     memcpy(artpack_list[i], p->data, strlen( (char*) p->data ) + 1);
  19.     printf("loading artpack %s\n", artpack_list[i]);
  20.     if(strstr(artpack_list[i], "default") == artpack_list[i])
  21.       artpack_index = i;
  22.     i++;
  23.  
  24.   }
  25.   printf("loaded %d artpacks\n", i);
  26.   artpack_list[i] = NULL;
  27. }
  28.  
  29. void reloadArt() {
  30.   printf("reloading art\n");
  31.   deleteTextures(game->screen);
  32.   game->screen->artpack.path = artpack_list[artpack_index];
  33.   initTexture(game->screen);
  34. }
  35.     
  36.  
  37.